<HTML><HEAD><TITLE>append(?List1, ?List2, ?List3)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(lists)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>append(?List1, ?List2, ?List3)</H1>
Succeeds if List3 is the result of appending List2 to List1.


<DL>
<DT><EM>?List1</EM></DT>
<DD>List or variable.
</DD>
<DT><EM>?List2</EM></DT>
<DD>List or variable.
</DD>
<DT><EM>?List3</EM></DT>
<DD>List or variable.
</DD>
</DL>
<H2>Description</H2>
   Unifies List3 to the result of appending List2 to List1.  On
   backtracking append/3 gives all possible solutions for List1 and List2,
   if both are uninstantiated.
<P>
   The definition of this Prolog library predicate is:
<PRE>
append([],X,X).
append([X|L1],L2,[X|L3]):-
        append(L1,L2,L3).
</PRE>
   This predicate does not perform any type testing functions.
	
<H3>Modes and Determinism</H3><UL>
<LI>append(+, +, -) is det
<LI>append(-, -, +) is multi
</UL>
<H3>Fail Conditions</H3>
   Fails if List3 does not unify with the result of appending List2 to
   List1.


<H3>Resatisfiable</H3>
   Yes.
<H2>Examples</H2>
<PRE>
Success:
  append([1,2],L2,[1,2,3,4]). (gives L2=[3,4]).
  append([1,B],L2,[A,2,3,4]). (gives B=2 L2=[3,4] A=1).
  append([1,2],L2,L3).        (gives L2=_g70 L3=[1,2|_g70]).
  append([1]),[2,3]),L3).     (gives L3=[1,2,3]).

  [eclipse]: append(L1,L2,[1,2]), writeln((L1,L2)), fail.
  [] , [1, 2]
  [1] , [2]
  [1, 2] , []
  no (more) solution.
Fail:
  append(L1,[3],[1,2,3,4]).
  append(1,L2,[1,2]).


</PRE>
<H2>See Also</H2>
<A HREF="../../lib/lists/union-3.html">union / 3</A>
</BODY></HTML>
